home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 April: Mac OS SDK / Dev.CD Apr 99 SDK1.toast / Development Kits / Apple Remote Access API / Remote Access 2.0 API / RemoteAccessInterface.h next >
Encoding:
C/C++ Source or Header  |  1993-11-04  |  13.3 KB  |  311 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        RemoteAccessInterface.h
  3.  
  4.     Contains:    Interface for making remote access calls.
  5.  
  6.     Copyright:    © 1991-1994 Apple Computer, Inc.
  7.          All Rights Reserved.
  8.  
  9. */
  10.  
  11.  
  12. #ifndef REMOTEACCESSINTERFACE_H
  13. #define REMOTEACCESSINTERFACE_H
  14.  
  15. #include <Types.h>
  16. #include <files.h>
  17. #include <AppleTalk.h>
  18. #include <Standard.h>
  19.  
  20. typedef     pascal void (*UserStatusProcPtr)(uPtr, uPtr);
  21. typedef     pascal long (*PacketFilterProcPtr)(uPtr, ulong, ulong, uPtr, ulong);
  22. typedef     pascal void (*RemmaperProcPtr)(ulong, ulong, ulong, uPtr, uPtr);
  23. typedef     pascal void (*CallBackHookProcPtr)(uPtr, ulong);
  24. typedef     pascal void (*CallBackCompHookProcPtr)(uPtr);
  25. typedef     pascal ulong (*NetValidProcPtr)(uPtr,AddrBlock);
  26.  
  27.  
  28. #define REMOTEACCESSNAME         "\pRemote Access"
  29. #define REMOTEACCESSID            'strm'                    // *** NOTE: "Network Extension" uses this id for its _Gestalt call
  30.  
  31. #define gestaltRemoteAccessAttr    REMOTEACCESSID
  32. #define gestaltRemoteAccessExists    0
  33.  
  34. #define gestaltRemoteAccessCallOnly    1                    /* Remote Access Client */
  35. #define gestaltRemoteAccessMPServer    2                    /* Remote Access multi-port server */
  36. #define gestaltRemoteAccessVers2    3                    /* ARA 2.0 features are available */
  37.  
  38. #define MAXSTATUSMSGSIZE        256
  39. #define USERNAMESIZE            34
  40. #define PASSWORDSIZE            8
  41. #define PASSWORDBUFSIZE            PASSWORDSIZE+1
  42.  
  43. #define TIME_UNLIMITED            0xffffffff                /* indicates unlimited time allowed on connection */
  44.  
  45.  
  46. #define ctlir_getConnectInfo 0x01                        /* will get connect info if address is remote */
  47. #define ctlir_disposeConnectInfo 0x02                    /* will dispose info in connectInfoPtr properly */
  48.  
  49.  
  50. /* control codes
  51. */
  52. #define RAM_EXTENDED_CALL                23                /* make an extended call (use TRemoteAccessParamBlock)    */
  53.  
  54. /* extended codes (must have control code set to RAM_EXTENDED_CALL)
  55. */
  56. /* the first group of calls can be issued without doing a load */
  57. #define CmdRemoteAccess_Load            1                /* loads main section of remote access */
  58. #define CmdRemoteAccess_Unload            2                /* unloads main section */
  59. #define CmdRemoteAccess_PassWordMunger    6                /* create a munged password */
  60. #define CmdRemoteAccess_GetCodeHooks    7                /* get code hooks */        
  61.  
  62. /* calls that will not work until CmdRemoteAccess_Load has been done */
  63. #define    CmdRemoteAccess_DoConnect                40                /* main thread only */
  64. #define CmdRemoteAccess_Disconnect                42                /* disconnect */
  65. #define CmdRemoteAccess_Status                    45                /* get status information */
  66. #define CmdRemoteAccess_IsAddressRemote            53                /* main thread only when getting/setting connect pb info */                        
  67.  
  68. /* Remote Access errors */
  69. #define ERR_BASE                        -5800
  70.  
  71. #define ERR_NOTCONNECTED                (ERR_BASE-0)
  72. #define ERR_CONNECTIONABORTED            (ERR_BASE-1)
  73. #define ERR_ALREADYCONNECTED            (ERR_BASE-2)
  74. #define ERR_COMMANDALREADYINPROGRESS    (ERR_BASE-3)
  75. #define ERR_BADVERSION                    (ERR_BASE-4)
  76. #define ERR_INSHUTDOWN                    (ERR_BASE-5)
  77. #define ERR_CONNECTIONABORTING            (ERR_BASE-6)
  78. #define ERR_ALREADYENABLED                (ERR_BASE-7)
  79. #define ERR_ZONEBUFBADSIZE                (ERR_BASE-8)
  80. #define ERR_CONNECTTIMEDOUT                (ERR_BASE-9)
  81. #define ERR_CONNECTUSERTIMEDOUT            (ERR_BASE-10)
  82. #define    ERR_BADPARAMETER                (ERR_BASE-11)
  83. #define    ERR_NOMULTINODE                    (ERR_BASE-12)
  84. #define    ERR_ATALKNOTACTIVE                (ERR_BASE-13)
  85. #define    ERR_NOCALLBACKSUPPORT            (ERR_BASE-14)
  86. #define    ERR_NOTOPENEDBYTHISPB            (ERR_BASE-15)
  87. #define ERR_NOGLOBALS                    (ERR_BASE-16)
  88. #define ERR_NOSMARTBUFFER                (ERR_BASE-17)
  89. #define ERR_BADATALKVERS                (ERR_BASE-18)
  90. #define ERR_VLD8_CONNECT                0
  91. #define ERR_VLD8_CALLBACK                (ERR_BASE-19)
  92. #define ERR_VLD8_BADVERSION                (ERR_BASE-20)
  93. #define ERR_VLD8_BADUSER                (ERR_BASE-21)
  94. #define ERR_VLD8_BADPASSWORD            (ERR_BASE-22)
  95. #define ERR_VLD8_BADLINK                (ERR_BASE-23)
  96. #define    ERR_VLD8_NOCALLBACKALLOWED        (ERR_BASE-24)
  97. #define    ERR_VLD8_ALLCBSERVERSBUSY        (ERR_BASE-25)
  98. #define    ERR_VLD8_GUESTNOTALLOWED        (ERR_BASE-26)
  99. #define ERR_VLD8_SERVERISIMPOSTER        (ERR_BASE-27)
  100. #define ERR_VLD8_LOGINNOTENABLED        (ERR_BASE-28)
  101. #define ERR_REMOTEPORTALREADYEXISTS        (ERR_BASE-29)
  102. #define ERR_OPENNOTALLOWED                (ERR_BASE-30)
  103. #define ERR_NOUSERSANDGROUPS            (ERR_BASE-31)
  104. #define ERR_PORTSHUTDOWN                (ERR_BASE-32)
  105. #define ERR_PORTDOESNOTEXIST            (ERR_BASE-33)
  106. #define ERR_PWNEEDEDFORENABLE            (ERR_BASE-34)
  107. #define ERR_DAMAGED                        (ERR_BASE-35)
  108. #define ERR_NETCONFIGCHANGED            (ERR_BASE-36)
  109. /* 2.0 and above only… */
  110. #define    ERR_NOSUPPORT_ATREMOTE            (ERR_BASE-37)
  111. #define ERR_CONFLICTING_REQUEST            (ERR_BASE-38)
  112. #define    ERR_VLD8_INVALIDAUTHMETHOD        (ERR_BASE-39)
  113. #define    ERR_VLD8_CONTINUE                (ERR_BASE-40)
  114. #define    ERR_PWCHANGECANCEL                (ERR_BASE-41)
  115. #define ERR_VLD8_MANUALPASSWORDREQUIRED (ERR_BASE-50)
  116.  
  117. #define ERR_END                            ERR_VLD8_MANUALPASSWORDREQUIRED    /* must be last error */
  118.  
  119.  
  120. #define kTemplateVers            1        /* current version understood by remote access for the connect template */
  121.  
  122. /* forward defs */
  123. typedef union TRemoteAccessParamBlock *TPRemoteAccessParamBlock;
  124.  
  125.  
  126. /* network transition */
  127. struct TNetworkTransition
  128. {
  129.     unsigned char                *privateVars;            /* pointer used internally by Remote Access */
  130.     NetValidProcPtr                netValidProc;            /* pointer to the network valid procedure */
  131.     Boolean                        newConnectivity;        /* set to true if new connectivity, false if loss of connectivity */
  132. };
  133. typedef struct TNetworkTransition TNetworkTransition;
  134. typedef TNetworkTransition *TPNetworkTransition;
  135.  
  136.  
  137. #define DControlParamHeader \
  138.     QElem                        *qLink;                    /*next queue entry*/\
  139.     short                        qType;                    /*queue type*/\
  140.     short                        ioTrap;                    /*routine trap*/\
  141.     Ptr                            ioCmdAddr;              /*routine address*/\
  142.     ProcPtr                        ioCompletion;            /*completion routine*/\
  143.     OSErr                        ioResult;                /*result code*/\
  144.     long                        userData;                /*for use by the user */\
  145.     short                        unused;                    /*unused field */\
  146.     short                        ioRefNum;                /*driver reference number*/\
  147.     short                        csCode;                    /*Call command code*/
  148.  
  149. #define DExtendedParam \
  150.     DControlParamHeader \
  151.     Ptr                            hReserved1; \
  152.     Ptr                            hReserved2; \
  153.     Ptr                            resultStrPtr; \
  154.     Ptr                            extendedType;            /* pointer to identifier string */
  155.  
  156.  
  157. #define DRemoteAccessParmHeader    \
  158.     DExtendedParam \
  159.     short                        extendedCode;            /* for use by extended call proc */\
  160.     Ptr                            portGlobalsPtr;            /* pointer to globals for this port (0=userport) */\
  161.  
  162.  
  163. struct TRemoteAccessParmHeader
  164. {
  165.     DRemoteAccessParmHeader
  166. };
  167. typedef struct TRemoteAccessParmHeader TRemoteAccessParmHeader;
  168.  
  169.  
  170. struct TRAConnectInfoTemplate
  171. {
  172.     unsigned long                version;                /* version of this format            */
  173.     unsigned long                ltType;                    /* Link Tool type                    */
  174.     long                        addressInfoLength;        /* length of the address information */
  175.     Ptr                            addressInfoPtr;            /* pointer to connect address info */
  176.     long                        ltSpecificTemplateLength;/* length of the ltspecific information */
  177.     Ptr                            ltSpecificTemplatePtr;    /* pointer to link tool specific params */
  178.     unsigned char                passWord[PASSWORDBUFSIZE];    /* user password                    */
  179.     unsigned char                userName[USERNAMESIZE];    /* user name                        */
  180.     unsigned long                connectReminderTimer;    /* value for connection    reminder in seconds    */
  181.     unsigned long                connectOKWaitTimer;        /* how long to wait for OK on reminder timer    */
  182.     Boolean                        guestLogin;                /* try to log in as a guest            */
  183.     Boolean                        passwordSaved;            /* set if password is saved            */
  184.     Boolean                        guaranteedAccess;        /* flag to guarantee access to servers internet */
  185.  
  186. };
  187. typedef struct TRAConnectInfoTemplate TRAConnectInfoTemplate;
  188. typedef TRAConnectInfoTemplate *TPRAConnectInfoTemplate;
  189.  
  190.  
  191. /* connect option flags
  192. */
  193. #define kNSCanInteract            0x00000001                // User interaction (password prompt) is OK 
  194. #define    kNSShowStatus            0x00000002                // show the status of the connect or disconnect call 
  195. #define    kNSConnectDocument        0x00000004                // connect using the specified document 
  196. #define    kNSPassWordSet            0x00000010                // use the specified password field when connecting by document 
  197. // 2.0 and above…
  198. #define kNS2SavvyFlags            0x40000000                // Set to use the next 2 flags below for only ARA 2.0 aware applications.
  199. #define    kNSAR2Connection        0x00000020                // connecting to a 2.0 server. 
  200. #define    kNSNotifyWhileConnected    0x00000040                // display cute notification icon while connected.
  201.  
  202. struct TRemoteAccessConnectParam
  203. {
  204.     DRemoteAccessParmHeader
  205.     TRAConnectInfoTemplate        connectInfo;            /* The connection infomation template */
  206.     unsigned long                optionFlags;            // bit mapped connect option flags 
  207.     FSSpec                        fileInfo;                // file info for connect document 
  208. };
  209. typedef struct TRemoteAccessConnectParam TRemoteAccessConnectParam;
  210.  
  211.  
  212. #define kNumWarnEntriesMax        5                        /* number of entries in warn array */
  213. struct TRemoteAccessDisconnectParam
  214. {
  215.     DRemoteAccessParmHeader
  216.     unsigned long                disconnectin;            /* server mode: disconnect in # of seconds */
  217.     TPRemoteAccessParamBlock    abortOnlyThisPB;        /* only abort a connection opened by this pb */
  218.     unsigned long                 warnArr[kNumWarnEntriesMax];    /* set warn times here in seconds (zero all if no warnings) */
  219.     unsigned long                optionFlags;            /* bit mapped connect option flags */
  220. };
  221. typedef struct TRemoteAccessDisconnectParam TRemoteAccessDisconnectParam;
  222.  
  223.  
  224. /* bits passed back in status call */
  225. #define CctlConnected                0x00000001        /* set when connected */
  226. #define CctlAnswerEnable            0x00000004        /* set when we are set to answer calls */
  227. #define CctlServerMode                0x00000008        /* set for server mode, clear for remote mode */
  228. #define CctlConnectionAborting        0x00000010        /* connection is being torn down */
  229. #define CctlConnectInProg            0x00000020        /* set when connection in progress or fully connected */
  230. #define CctlDisconnectInStarted        0x00008000        /* somebody has started a disconnectIn */
  231. #define    CctlGuestMode                0x00080000        /* set if this port is logged on with guest access */
  232. #define ctlAR2Connection            0x02000000        /* set when this connection is to a 2.0 server */
  233. #define ctlNotifyWhileConnected     0x04000000        /* set when the user wants to be reminded while connected */
  234. #define ctlConnectedToMPS           0x08000000        /* set when client is connected to a multi-port server */
  235. #define CctlMultiNodeReady            0x80000000        /* shows if we currently have a multinode address */
  236. struct TRemoteAccessStatusParam
  237. {
  238.     DRemoteAccessParmHeader
  239.     unsigned long                statusBits;                /* bits for current status */
  240.     unsigned long                timeConnected;            /* number of seconds we have been connected */
  241.     unsigned long                timeLeft;                /* number of seconds remaining in connection (0xffffffff infinite) */
  242.     unsigned char                *userNamePtr;            /* returns user name, expects pointer to buffer of USERNAMESIZE if non nil */
  243.     unsigned char                *connectedToNamePtr;    /* returns name of where we connected to, expects pointer to buffer of USERNAMESIZE if non nil */
  244.     TPRemoteAccessParamBlock    connectedByParamPtr;    /* a pointer to the parameter block "initiating" the connection if we are connected */    
  245.     TPRemoteAccessParamBlock    statusConnectedByParamPtr;    /* a pointer to the parameter block "initiating" the connection when status was posted */
  246.     unsigned char                *theLastStatusMsgPtr;    /* expects pointer to buffer of size MAXSTATUSMSGSIZE */
  247.     unsigned char                *statusUserNamePtr;        /* pointer to buffer of size USERNAMESIZE */
  248.     long                        statuslttype;            /* link tool type */
  249.     long                        statusmsgOptionFlags;    /* classification of message type */
  250.     long                        statusMsgNum;            /* specific message number */
  251.     long                        statusMsgSeqNum;        /* pass in zero if always want status, otherwise use last value, if status is new, new number is returned */
  252.     unsigned long                userSignature;            /* signature of port creator */
  253.     unsigned long                userRefCon;                /* refcon of port creator */
  254. };
  255. typedef struct TRemoteAccessStatusParam TRemoteAccessStatusParam;
  256.  
  257.  
  258. struct TRemoteAccessIsRemoteParms
  259. {
  260.     DRemoteAccessParmHeader
  261.     long                        theAddress;                /* address that is to be checked */
  262.     unsigned long                optionFlags;            /* Set to ctlir_getConnectInfo or ctlir_disposeConnectInfo, if zero only checks address */
  263.     Boolean                        locationIsRemoteFlag;    /* returns true    if address is remote */    
  264.     long                        ConnectInfoLength;        /* length of the following data */
  265.     TPRAConnectInfoTemplate        connectInfoPtr;            /* The connection information template pointer */
  266. };
  267. typedef struct TRemoteAccessIsRemoteParms TRemoteAccessIsRemoteParms;
  268.  
  269. struct TRemoteAccessPasswordMunger
  270. {
  271.     DRemoteAccessParmHeader
  272.     unsigned char                *userNamePtr;            /* pointer to username string */
  273.     unsigned char                *passWordPtr;            /* user password */    
  274.     unsigned short                reserved;                /* must set to zero */
  275. };
  276. typedef struct TRemoteAccessPasswordMunger TRemoteAccessPasswordMunger;
  277.  
  278.  
  279. struct TRemoteAccessGetCodeHooks
  280. {
  281.     DRemoteAccessParmHeader
  282.     RemmaperProcPtr                remapperProc;            /* quick vector to remapper code */
  283. };
  284.  
  285. typedef struct TRemoteAccessGetCodeHooks TRemoteAccessGetCodeHooks;
  286.  
  287. /* this is the union of all the different command types */
  288. union TRemoteAccessParamBlock
  289. {
  290.     TRemoteAccessParmHeader        HDR;                    /* header pb */
  291.     TRemoteAccessParmHeader        LOAD;                    /* load pb */
  292.     TRemoteAccessParmHeader        UNLOAD;                    /* unload pb */
  293.     TRemoteAccessConnectParam    CONNECT;                /* connect pb */
  294.     TRemoteAccessDisconnectParam DISCONNECT;            /* disconnect pb */
  295.     TRemoteAccessStatusParam    STATUS;                    /* get current status */
  296.     TRemoteAccessIsRemoteParms    ISREMOTE;                /* used to check network address location */
  297.     TRemoteAccessPasswordMunger    MUNGEPW;                /* run password through munger */
  298.     TRemoteAccessGetCodeHooks    CODEHOOKS;                /* get internal code hooks */
  299.  
  300.     unsigned char                filler[256];            /* set the minimum size of this parameter block */
  301. };
  302. typedef union TRemoteAccessParamBlock TRemoteAccessParamBlock;
  303. typedef TRemoteAccessParamBlock *TPRemoteAccessParamBlock;
  304.  
  305.  
  306. /* externs */
  307. pascal OSErr PBRemoteAccess(TPRemoteAccessParamBlock paramBlock,Boolean async)
  308.     = {0x7000,0xAA5B}; 
  309.  
  310.  
  311. #endif